package cn.edu.nju.software.cdiy.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import cn.edu.nju.software.cdiy.bean.Scomment;
import cn.edu.nju.software.cdiy.dao.ScommentDao;
import cn.edu.nju.software.cdiy.service.ScommentService;

public class ScommentServiceImpl  implements ScommentService{

	@Autowired
	private ScommentDao scommentDao;

	public void setScommentDao(ScommentDao scommentDao) {
		this.scommentDao = scommentDao;
	}

	@Override
	public Scomment loadByScommentId(Long id) {
		return this.scommentDao.getScommentById(id);
	}

	@Override
	public List<Scomment> loadBySchemeId(Long schemeid) {
		return this.scommentDao.getSchemeComments(schemeid);
	}

	@Override
	public void deleteByScomentId(Long commentid) {
		 this.scommentDao.deleteByScomentId(commentid);
	}

	@Override
	public Scomment saveScomment(Scomment scomment) {
		java.sql.Date registerDate = new java.sql.Date(new java.util.Date().getTime());
		scomment.setTime(registerDate);
		return this.scommentDao.saveScomment(scomment);
	}

	@Override
	public int getScommentSize(Long id) {
		return this.scommentDao.getScommentSize(id);
	}

	@Override
	public List<Scomment> getScommentSelectList(Long id, int page, int pageSize) {
		return this.scommentDao.getScommentSelectList(id, page, pageSize);
	}

}
